package com.untrance.shop.core.builder.query;

import com.untrance.shop.common.enums.OrderDirectionType;
import com.untrance.shop.common.filters.model.CommentFilter;
import com.untrance.shop.model.Comment;

import javax.persistence.EntityManager;

/**
 * @author eugene zadyra
 */
public class CommentQueryBuilder extends AbstractPaginableQueryBuilder<CommentFilter> implements
		QueryBuilder{

	public CommentQueryBuilder(CommentFilter filter, EntityManager em) {
		this.em = em;
		this.filter = filter;
		addFilters();
	}

	@Override
	protected void addFilters() {
		addFilterValue("productKey", filter.getProductKey());
		addFilterValue("userKey", filter.getUserKey());
	}

	@Override
	protected OrderDirectionType getDefaultOrderDirection() {
		return OrderDirectionType.DESC;
	}

	@Override
	protected String getEntityName() {
		return Comment.class.getName();
	}

	@Override
	protected String getOrderField() {
		return "timeAdded";
	}
}
